﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Linq;

namespace BYS.XiAnComDept.App
{
    public static class UIHelper
    {
        public const int StartYear = 2000;

        public static List<int> GetAllYears()
        {
            List<int> allYears = new List<int>();
            for (int i = StartYear; i <= DateTime.Now.Year; i++)
            {
                allYears.Add(i);
            }
            return allYears;
        }

        public static Dictionary<int, string> ConvertToDict(this List<int> items, bool isAddNull)
        {
            Dictionary<int, string> results = new Dictionary<int, string>();
            if (isAddNull)
            {
                results.Add(-1, string.Empty);
            }
            foreach (int i in items)
            {
                results.Add(i, i.ToString());
            }
            return results;
        }

        public static List<string> GetAllFundStatus()
        {
            return new List<string>() { "申请中", "基本通过","通过" };
        }

        public static bool ShowError(this UserControl control,  string errorMsg)
        {
            if (errorMsg.Trim().Length == 0)
            {
                return false;
            }
            else
            {
                MessageBox.Show("部分数据输入有误，如\n" +　errorMsg, "输入有误!");
                return true;
            }
        }

    }
}
